<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Map</title>
  </head>
  <body>
    <script>
      // 声明一个Map对象
      let m = new Map();

      // 添加元素
      m.set("name", "xinxin");
      m.set("change", function () {
        console.log("改变");
      });

      let key = {
        school: "ATGUIGU",
      };

      // 对象作为Map的键
      m.set(key, ["北京,上海,深圳"]);

      // 删除元素
      m.delete("name");

      // 获取元素
      console.log(m.get("change"));
      console.log(m.get(key));

      // 检测
      console.log(m.has("name"));

      // 清空
      // m.clear();

      // 遍历
      for (let v of m.values()) {
        console.log(v);
      }

      console.log(m, m.size);
    </script>
  </body>
</html>
